# 导包
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score,precision_score,recall_score,f1_score,roc_auc_score,classification_report
from sklearn.model_selection import train_test_split
import joblib
# 获取数据
data=pd.read_csv(r"./test2.csv")
print(data.info())
data=pd.get_dummies(data)
print(data.info())
x = data[['OverTime_Yes', 'Department_Sales', 'BusinessTravel_Travel_Rarely',
'JobRole_Sales Representative','Gender_Male','EducationField_Other',
'YearsWithCurrManager','WorkLifeBalance','TrainingTimesLastYear','Education','JobLevel',
'MaritalStatus_Married','MonthlyIncome','DistanceFromHome','EnvironmentSatisfaction',
'JobInvolvement','NumCompaniesWorked','StockOptionLevel'
]]
y = data['Attrition']
#创建模型对象
# 模型实例化
es = joblib.load('./人才流失4.pkl')
# 模型预测
y_pre = es.predict_proba(x)[:,1]
print(f"AUC:{roc_auc_score(y,y_pre)}")
